<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title> 自己测试 </title>
</head>
<body>
    <div id="app">
            姓：<input type="text" v-model="name1"><br/>
            名：<input type="text" v-model="name2"><br/>
            姓名：<input type="text"  v-model="name3" ><br/>
    </div>

</body>
</html>
<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript">
     new Vue({
        el:"#app",
        data:{
            name1:"a",
            name2:"b",
        },
        computed:{
            name3:{
                get:function(val) {
                    console.log('get' + val)
                    return this.name3 = this.name1 + '_' + this.name2
                },
                set:function(val) {
                    const str = val.split('_')
                    this.name1 = str[0] ? str[0] : ""
                    this.name2 = str[1] ? str[1] : ""
                    return this.name1 + '_' + this.name2
                }
            }
        }
    })
</script>